<html>
<head>
<link rel='stylesheet' href='../../js/sh/SyntaxHighlighter.css' type='text/css' />
<script src='../../js/sh/shCore.js'></script>
<script src='../../js/sh/shBrushJava.js'></script>
<style>
* {
font-family:Courier New,monospace;
  padding: 0;
  margin: 0;
  white-space: nowrap;
  font-size: 11px;
}
.dp-highlighter {
  white-space: nowrap;
  overflow: visible;
  width: 600px;
  font-size: 11px;
  font-family:Courier New,monospace;
}
</style>
</head>
<body>
<textarea name='code' class='java:nogutter' rows='15' cols='120'>
package com.smartgwt.sample.showcase.client.data;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.google.gwt.core.client.GWT;

public class SupplyCategoryXmlDS extends DataSource {

    private static SupplyCategoryXmlDS instance = null;

    public static SupplyCategoryXmlDS getInstance() {
        if (instance == null) {
            instance = new SupplyCategoryXmlDS("supplyCategoryDS");
        }
        return instance;
    }

    public SupplyCategoryXmlDS(String id) {

        setID(id);
        setRecordXPath("/List/supplyCategory");


        DataSourceTextField itemNameField = new DataSourceTextField("categoryName", "Item", 128, true);
        itemNameField.setPrimaryKey(true);

        DataSourceTextField parentField = new DataSourceTextField("parentID", null);
        parentField.setHidden(true);
        parentField.setRequired(true);
        parentField.setRootValue("root");
        parentField.setForeignKey("supplyCategoryDS.categoryName");


        setFields(itemNameField, parentField);

        setDataURL("ds/test_data/supplyCategory.data.xml");
        
        setClientOnly(true);

    }
}
</textarea>
<script class='javascript'>
dp.SyntaxHighlighter.HighlightAll("code");
</script>
</body>
</html>
